export default function registerSwitch(lf) {
    lf.register('switch', ({ DiamondNode, DiamondNodeModel }) => {
        class Model extends DiamondNodeModel {
            constructor(data, graphModel) {
                super(data, graphModel)
                    // this.radius = 4;
            }

            initNodeData(data) {
                data.text = {
                    value: (data.text && data.text.value) || 'switch',
                    x: data.x,
                    y: data.y,
                }
                super.initNodeData(data)
            }

            // 审批过后变绿
            setAttributes() {
                this.rx = 40
                this.ry = 40
            }

            getNodeStyle() {
                const style = super.getNodeStyle()
                const { properties: { isExecuted, isPassed } } = this;
                if (isExecuted) {
                    style.stroke = 'green'
                }
                // 走过绿色
                if (isPassed) {
                    style.strokeWidth = '2'
                    style.stroke = 'green'
                }
                return style
            }

        }


        return {
            view: DiamondNode,
            model: Model
        }
    })
}